#include "Connect.h"
Connect connect;
Connect::Connect(){
  
}

bool Connect::connectWiFi(const char* ssid,const char* password){
  IPAddress staticIP("192.168.3.176");//ESP8266的IP地址
  IPAddress gateway("192.168.3.1"); //网关IP地址
  IPAddress subnet("255.255.255.0");//子网掩码
  WiFi.config(staticIP,gateway,subnet);//设置静态ip
  WiFi.mode(WIFI_STA);//设置为无线终端模式
  WiFi.begin(ssid,password);//连接指定的wifi;
  if(WiFi.waitForConnectResult()!=WL_CONNECTED){
    Serial.println("WiFi Failed");//连接失败返回
    return false;
  }
  Serial.println("WiFi connection successful!");
  Serial.printf("IP: %s\n", WiFi.localIP().toString().c_str());
  return true;
}